package atguigu.thread.task;

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;  
  
public class CustomThreadPoolExecutor {  
    public static void main(String[] args) {  
        // 创建一个固定大小的线程池  
        ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);  
  
        // 提交任务给线程池执行  
        executor.execute(() -> {  
            System.out.println("Task 1 is running in thread " + Thread.currentThread().getName());  
        });  
  
        executor.execute(() -> {  
            System.out.println("Task 2 is running in thread " + Thread.currentThread().getName());  
        });  
  
        // 关闭线程池  
        executor.shutdown();  
    }  
}